package com.jar.exercise.io.文件操作;

import java.io.File;

public class Demo2 {
	public static void main(String[] args) throws Exception {
		Demo2.listDirectioy(new File("D:/1"));
	}

	public static void listDirectioy(File dir) throws Exception {
		if (!dir.exists()) {
			throw new IllegalArgumentException("Ŀ¼:" + dir + "������");
		} else if (!dir.isDirectory()) {
			throw new IllegalArgumentException(dir + "����Ŀ¼");
		} else {
			File[] files = dir.listFiles();
			if (files.length > 0 && files != null) {

				for (int i = 0; i < files.length; i++) {

					if (files[i].isDirectory()) {
						listDirectioy(files[i]);
					} else {
						System.out.println(files[i].getName());
					}
				}
			}

		}
	}
}
